
import { myRequest } from '@/utils/request';

const quizService = {

    getMcqQuestion: () => {
        return new Promise((resolve, reject) => {
            myRequest.request({
                url: 'api/quiz/mcq',
                method: 'GET',
                success: (res) => resolve(res),
                error: (err) => reject(err),
            });
        });
    },
    /**
     * Submits a user's answer for a multiple-choice question.
     * @param {string} questionId - The ID of the question being answered.
     * @param {string} userAnswer - The answer selected by the user.
     */
    submitMcqAnswer: (questionId, userAnswer) => {
        return new Promise((resolve, reject) => {
            myRequest.request({
                url: 'api/quiz/mcq/submit',
                method: 'POST',
                data: {
                    questionId,
                    userAnswer,
                },
                success: (res) => resolve(res),
                error: (err) => reject(err),
            });
        });
    },
};

export default quizService;
